var app = new Vue({
	el: '#app',
	data: {
		value1: 1,
		url: 'http://114.215.83.227:809/admin/',
		phone: '请点击',
		phoneList: [],
		username: '',
		carList: [],
		userStatus: [
			{
				value: '已认证',
				label: '已认证'
			},
			{
				value: '未认证',
				label: '未认证'
			},
		],
		selectStatus:[],




	},
	methods: {

		//userIdPhone =  userid 
		// getid(){

		// 	var userIdPhone = sessionStorage.getItem("userIdPhone"); //获取数据token

		// 	console.log('huoqu:'+userIdPhone)

		// },

		// get1(){

		// 	console.log('get1:'+1)
		// },
		// get2(){

		// 	console.log('get1:'+2)
		// },

		//根据用户id获取电话信息
		ByIdGetPhone() {
			var vm = this;
			var userIdPhone = sessionStorage.getItem("userIdPhone"); //获取数据token
			vm.username = sessionStorage.getItem("name");
			//console.log('params获取到的是:' + params.userId)

			var access_header = 'a' + sessionStorage.getItem("token"); //获取数据token
			// 	// //setTimeout(() => {
			this.$http.post(vm.url + 'adminGetPhoneListByUserId', {
				'userId': userIdPhone,
			}, {
				emulateJSON: true,
				headers: {
					'access_header': access_header
				}


			}).then(function(res) {
				if (res.data.status == 1) {
					console.log(res.data.message)
					vm.phoneList = res.data.message


					if (vm.phoneList == null) {

						vm.$Message.error('不可预知错误')


					}

				} else if (res.data.status == 0) {

					vm.$Message.error('获取失败，请重新登录')

				} else {
					vm.$Message.error('不可预知错误')
				}

			}, function(res) {
				vm.$Message.error('不可预知错误,联系管理员')
			});
			// //}, 5000);	
		},

		//userid获取该条车辆信息
		ByPhoneGetCarInfo() {
			var vm = this;
			var userIdPhone = sessionStorage.getItem("userIdPhone"); //获取数据token
			//console.log('ss  userPhoneId获取到的是:' + userIdPhone)
			var access_header = 'a' + sessionStorage.getItem("token"); //获取数据token
			// 	// //setTimeout(() => {
			this.$http.post(vm.url + 'adminGetCarListByUserId', {
				'userId': userIdPhone,
			}, {
				emulateJSON: true,
				headers: {
					'access_header': access_header
				}

			}).then(function(res) {
				if (res.data.status == 1) {
					vm.carList = res.data.message
					for (var i = 0; i < vm.carList.length; i++) {
						// 判断认证状态
						switch (vm.carList[i].carState) {
							case 1:
								vm.carList[i].carState = "未认证"
								break;
							case 2:
								vm.carList[i].carState = "已认证"
								break;
							default:
								break;
						}
						
						
						
						
						
					
						//console.log('vm.phoneList[0]获取到的是:' +vm.phoneList[0])
					}
					
	
					console.log('moredata:' + vm.carList[0].carState)
				} else if (res.data.status == 0) {

					vm.$Message.error('获取失败，请重新登录')
					

				} else {
					vm.$Message.error('不可预知错误')
				}

			}, function(res) {
				vm.$Message.error('不可预知错误,联系管理员')
			});
			// //}, 5000);	






		},
		// 修改用户认证状态
		changeStatus(index,carid,carState) {
			var vm = this
			
			console.log("moredatachangeStatusindex："+carid)
			console.log("moredatauserId："+carState)
			// console.log("111111statusUserId："+vm.statusUserId)
		 //    console.log("changeStatusindex："+vm.selectStatus[index])
			
			if (vm.selectStatus[index] == "未认证") {
				
				var carState = 1
				
			}else if(vm.selectStatus[index] == "已认证"){
				
				var carState = 2
							//console.log("auditState2："+auditState)
			}
			
			var access_header = 'a' + sessionStorage.getItem("token"); //获取数据token
			// setTimeout(() => {
				this.$http.post(vm.url + 'adminChangeUserCarStateByUserCarId', {
					'userCarId': carid,
					'carState':carState
				}, {
					emulateJSON: true,
					headers: {
						'access_header': access_header
					}
				}).then(function(res) {
					if (res.data.status == 1) {
						//vm.getUserList()
						console.log('111获取到的是:' + res.data.prompt)
						
						this.$Message.success('修改用户认证状态成功');
						
			
			
					} else if (res.data.status == 0) {
			
						vm.$Message.error('失败')
						
						//console.log('111获取到的是:' + res.data.message)
			
					} else {
						vm.$Message.error('不可预知错误')
					}
			
				}, function(res) {
					vm.$Message.error('不可预知错误,联系管理员')
				});
			// }, 5000);
			
			//ddd
			
			
		
		
		},











	},
	mounted() {
		this.ByIdGetPhone()
		this.ByPhoneGetCarInfo()
	},
	created() {


	},
	watch: {

	}


});
